{layout name="common/layout" /}
<link rel="stylesheet" type="text/css" href="__MERCHANT_STATIC__/style/css/message/message.css?v=2017.10.25" />
<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>

<div class="Hui-article-box" style="margin-top: 37px;">
		<div class="newCrumbs ">消息中心
				<span class="c-gray en">&gt;</span>系统消息
			</div>
	<div class="Hui-article">
		
				  <ul class="message_main_list">
						{foreach($systemMessage as $k2 => $v2)}
							<li class="message_main_single {if $v2['is_read'] eq '1'}message_main_single--read{else}message_main_single--unread{/if}" data-id="{$v2['message_id']}">
								<p class="message_main_text">
									{$v2['message_title']}
									<br>
									<br>
									{$v2['message_content']}
								</p>
								<span class="message_main_time">
									<span>
										<?php echo date('Y-m-d H:i:s', $v2['message_create_time']); ?>
									</span>	
									<span>
										<?php echo date('Y-m-d H:i:s', $v2['message_create_time']); ?>
									</span>	
								</span>
							</li>
						{/foreach}
					</ul>		
				<div>
					<div class="cl">
						{$data->render()}
					</div>
				</div>
	</div>
</div>
<script>
	$(".message_main_list").on("click",'.message_main_single',function(){
		var self=this;
		var id=$(this).data("id");
		/* 判断当前消息是否已读，已读消息不再发送请求 */
		if($(this).hasClass("message_main_single--show")){
			$(this).removeClass("message_main_single--show");
		}else{
			$(this).addClass("message_main_single--show");	
			$(this).siblings().removeClass("message_main_single--show");
			
		}
		if($(this).hasClass("message_main_single--read")){
			return false;
		}else{
			$.ajax({
			url: "../../api/message/readSysMessage",
			type: "POST",
			data: {
				msg_id:id
			},
			async: true,
			dataType: "json",
			success: function (response) {
                if (response.status == 1) {
                    $(self).removeClass("message_main_single--unread").addClass("message_main_single--read");
                    if($('#message_count').text() > 1) {
                        $('#message_count').text($('#message_count').text() - 1);
                    }else{
                        $('#message_count').hide();
                    }
                }
			},
			error: function (error) {

			}
			});
		}
	})

</script>
 

